﻿@using JQChart.Web.Mvc
@section Script
{
    <link href="~/Content/jqChartJQueryPlugin_3_8_5_0/css/jquery.jqChart.css" rel="stylesheet" />
    <link href="~/Content/jqChartJQueryPlugin_3_8_5_0/css/jquery.jqRangeSlider.css" rel="stylesheet" />
    <script src="~/Content/jqChartJQueryPlugin_3_8_5_0/js/jquery.jqChart.min.js"></script>
    <script src="~/Content/jqChartJQueryPlugin_3_8_5_0/js/jquery.jqRangeSlider.min.js"></script>

    <link href="~/Content/validBox/validBox.css" rel="stylesheet" />
    <script src="~/Content/validBox/validBox.js"></script>

    <!--[if IE]>
    <script src="~/Content/jqChartJQueryPlugin_3_8_5_0/js/excanvas.js"></script>
    <![endif]-->
}
@model List<Domain.Model.DTO.KeyValue<string, double>>

<div>
    @(Html.JQChart()
                .Chart(Model)
                .ID("jqChart")
                .Width(800)
                .Height(400)
                .Title("游戏豆单价走势图")
                .Animation(TimeSpan.FromSeconds(1))
                .Tooltips(el => el.TooltipsType(TooltipsType.Shared))
                .Axes(axis =>
                        {
                            axis.DateTimeAxis(Location.Bottom).Labels(el => el.ToString());
                        }
                )
                .Series(series =>
                    {
                        series.Line()
                              .Title("游戏豆单价")
                              .StrokeStyle("#418CF0")
                             
                              .XValues(el => el.Key)
                              .YValues(el => el.Value);

                    }
                )
                .Render()
          )
</div>
<form>
    <div class="control-group">
        <label class="control-label" for="Name">更改价格：</label>
        <div class="controls">
            @Html.TextBox("price","",Html.Valid().Required().Range(0.10d, 0.20d, "单价必须介于{0}和{1}之间").AsHtmlAttribute())
        </div>
    </div>
</form>
    <div class="control-group pull-left">
        <label class="control-label"></label>
        <div class="controls">
            <input type="button" onclick="saveForm(); return false;" class="btn btn-info" value="保存" />
          
        </div>
    </div>

<script type="text/javascript">
    function saveForm() {
        $('form').validBox(function (r) {
            if (r == false) return;
            $.post("/Trade/BeanPrice", $('form').serialize(), function (data) {
                if (data.state) {
                    location.href = data.value;
                } else {
                    window.messageBox('提示', data.value);
                }
            });
        });
    }

</script>
